//
//  courceDetailViewController.m
//  One Construction
//
//  Created by apple on 2019/9/7.
//  Copyright © 2019 apple. All rights reserved.
//

#import "courceDetailViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <CCVodSDK/DWSDK.h>
#import <CCVodSDK/DWPlayerView.h>
#import "advisoryViewController.h"
#import "DWTools.h"
@interface courceDetailViewController ()<DWVideoPlayerDelegate,UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)NSString *  videoId;
//播放器
@property(nonatomic,strong)DWPlayerView *playerView;
//播放视频上面的按钮，点击之后直接播放视频
@property(nonatomic,strong)UIButton *playerBtn;
@property(nonatomic,strong)NSMutableArray *dataArr;
@property(nonatomic,strong)DWPlayInfo * playInfo;
@property(nonatomic,strong)UIImageView *headBackImgView;
//图片上面的按钮，点击的时候判断有没有选择目录
@property(nonatomic,strong)UIButton *backBtn;
//播放视频下面的view；
@property(nonatomic,strong)UIView *bigView;
//目录里面的内容放到tableview中
@property(nonatomic,strong)UITableView *TableView;

@property(nonatomic,strong)UIButton *advisoryBtn;
@property(nonatomic,strong)UIButton *joinBtn;
//当前播放时间的数字
@property(nonatomic,assign)CGFloat currentTime;

//播放器底部的view
@property(nonatomic,strong)UIView *footView;
//时间滑动条
@property(nonatomic,strong)UISlider *durationSlider;
//切换屏幕按钮
@property(nonatomic,strong)UIButton *switchBtn;
//当前时间
@property(nonatomic,strong)UILabel *currentTimeLabel;

@property(nonatomic,strong)UILabel *totalTimeLabel;

@property(nonatomic,assign)BOOL isBigScreen;
//播放视频view的大小，
@property(nonatomic,strong)UIView *myView;
//小得播放按钮
@property(nonatomic,strong)UIButton *timeOutBtn;
//小得播放按钮
@property(nonatomic,strong)UIButton *smallPlayerBtn;

 @end

@implementation courceDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
    self.navigationItem.title = @"课程详情";
    [self getaData];
    [self creatUI];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)creatUI{
    
    self.headBackImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0,AppNavitionHright , ScreenWidth, 200)];
    [self.view addSubview:self.headBackImgView];
    [self.headBackImgView sd_setImageWithURL:[NSURL URLWithString:self.pic]];
    self.headBackImgView.backgroundColor = [UIColor redColor];
    self.headBackImgView.userInteractionEnabled = YES;
    self.backBtn = [[UIButton alloc]init];
    [self.headBackImgView addSubview:self.backBtn];
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.headBackImgView.mas_centerX);
        make.centerY.mas_equalTo(self.headBackImgView.mas_centerY);
        make.width.height.mas_equalTo(25);
    }];
    //       self.playerBtn.backgroundColor = [UIColor redColor];
    [self.backBtn setImage:[UIImage imageNamed:@"player"] forState:UIControlStateNormal];
    self.backBtn.hidden = NO;
    [self.backBtn addTarget:self action:@selector(clickBackBtn) forControlEvents:UIControlEventTouchUpInside];
    
    
    _playerView = [[DWPlayerView alloc]init];
    //        _playerView.
    _playerView.delegate = self;
    _playerView.timeOutLoad = 20;
    _playerView.timeOutBuffer= 20;
    //        _playerView.
    _playerView.frame = CGRectMake(0,0 , ScreenWidth, self.headBackImgView.frame.size.height);
    
    _playerView.backgroundColor = [UIColor blackColor];
    _playerView.videoGravity = AVLayerVideoGravityResizeAspectFill;//等比例填充
    [self.headBackImgView addSubview:_playerView];

    
    self.playerView.hidden = YES;
    self.playerBtn = [[UIButton alloc]init];
    [self.playerView addSubview:self.playerBtn];
    [self.playerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.playerView.mas_centerX);
        make.centerY.mas_equalTo(self.playerView.mas_centerY);
        make.width.height.mas_equalTo(25);
    }];
   
    
    self.footView = [[UIView alloc]init];
    self.footView.backgroundColor =  [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
    [self.playerView addSubview:self.footView];

    [self.footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(40);
    }];

 //切换屏幕按钮
    self.switchBtn = [[UIButton alloc]init];
    [self.switchBtn setImage:[UIImage imageNamed:@"switch"] forState:UIControlStateNormal];
    [self.footView addSubview:self.switchBtn];
    [self.switchBtn addTarget:self action:@selector(clickSwitchBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.mas_offset(-10);
        make.width.height.mas_equalTo(30);
    }];
    [self.footView addSubview:self.totalTimeLabel];
    [self.totalTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.right.mas_equalTo(self.switchBtn.mas_left).mas_offset(-10);
        make.top.mas_offset(13);
        make.width.mas_equalTo(55);
          make.height.mas_equalTo(14);
        
    }];
    [self.footView addSubview:  self.currentTimeLabel ];
    [self.currentTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(13);
        make.width.mas_equalTo(55);
        make.height.mas_equalTo(14);
        make.left.mas_offset(45);
    }];
    self.durationSlider = [[UISlider alloc]init];
//    self.durationSlider.continuous = YES;
    self.durationSlider.tintColor = [UIColor orangeColor];
    [self.footView addSubview:self.durationSlider];
    self.durationSlider.minimumValue = 0.0;
    self.durationSlider.maximumValue = 1.0;
    [self.durationSlider mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.currentTimeLabel.mas_right).mas_offset(5);
make.right.mas_equalTo(self.totalTimeLabel.mas_left).mas_offset(-10);
        make.top.mas_offset(19);
         make.height.mas_equalTo(2);
    }];
    
    [self.footView addSubview:self.smallPlayerBtn];
    [self.smallPlayerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(18);
        make.top.mas_offset(10);
        make.width.mas_equalTo(20);
         make.height.mas_equalTo(20);
    }];
    self.smallPlayerBtn.hidden = YES;
     [self.smallPlayerBtn addTarget:self action:@selector(clickSmallPlayerBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.footView addSubview:self.timeOutBtn];
    [self.timeOutBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(18);
        make.top.mas_offset(10);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
     self.timeOutBtn.hidden = NO;
    [self.timeOutBtn addTarget:self action:@selector(clickTimeOutBtn) forControlEvents:UIControlEventTouchUpInside];
    
    [self.playerBtn setImage:[UIImage imageNamed:@"player"] forState:UIControlStateNormal];
    self.playerBtn.hidden = YES;
    [self.playerBtn addTarget:self action:@selector(clickTheButtonToStartPlaying) forControlEvents:UIControlEventTouchUpInside];

    
    self.bigView = [[UIView alloc]initWithFrame:CGRectMake(0, self.headBackImgView.frame.origin.y+self.headBackImgView.frame.size.height, ScreenWidth, 69)];
    self.bigView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.bigView];
    
    myLable *topLable =[[myLable alloc] initWithFrame:CGRectMake(9, 11, ScreenWidth, 25)];
    [self.bigView addSubview:topLable];
    [topLable setLabletextColor:[UIColor blackColor] Text:self.bt TextFont:18];
    UIImageView *readImgView = [[UIImageView alloc]init];
    readImgView.image = [UIImage imageNamed:@"learn"];
    myLable *studyLable = [[myLable alloc]init];
    NSString *str= [NSString stringWithFormat:@"%@人学习",self.xx_rs];
    [studyLable setLabletextColor:[UIColor colorWithRed:187/255.0 green:187/255.0 blue:187/255.0 alpha:1.0] Text:str TextFont:14];
    [self.bigView addSubview:studyLable];
    [studyLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(0);
        make.bottom.mas_offset(-7);
        make.width .mas_equalTo(100);
        make.height .mas_equalTo(20);
    }];
    
    [self.bigView addSubview:readImgView];
    [readImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(-13);
        make.width.mas_equalTo(13);
        make.height.mas_equalTo(15);
        make.right.mas_equalTo(studyLable.mas_left).mas_offset(-3);
        
    }];
    
    [self.view addSubview:self.TableView];
    [self.TableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.bigView.mas_bottom).mas_offset(0);
         make.width.mas_equalTo(ScreenWidth);
        make.left.mas_offset(0);
        make.bottom.mas_offset(-50);
        
    }];
    
    [self.view addSubview:self.advisoryBtn];
    [self.advisoryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
      make.left.mas_offset(0);
        make.width.mas_equalTo(ScreenWidth/2);
        make.bottom.mas_offset(-0);
         make.height.mas_equalTo(49);
    }];
    [self.advisoryBtn addTarget:self action:@selector(clickAdvbtn) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.view addSubview:self.joinBtn];
    [self.joinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(0);
        make.width.mas_equalTo(ScreenWidth/2);
        make.bottom.mas_offset(-0);
        make.height.mas_equalTo(49);
    }];
    self.joinBtn.userInteractionEnabled =YES;
    [self.joinBtn addTarget:self action:@selector(clickJoinBtn) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)clickTimeOutBtn{
    if ([User sharedUUser].isLogin == YES) {
        self.smallPlayerBtn.hidden = NO;
        self.timeOutBtn.hidden = YES;
        self.playerBtn.hidden= YES;
        [self.playerView play];
    }
    else{
          [ProgressHUD showText:@"请先登录" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:2.0];
 
    }
}
- (void)clickSmallPlayerBtn{
    if ([User sharedUUser].isLogin == YES) {
        self.timeOutBtn.hidden = NO;
        self.smallPlayerBtn.hidden = YES;
        self.playerBtn.hidden= NO;
        
        [self.playerView pause];
    }
    else{
        [ProgressHUD showText:@"请先登录" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:2.0];
        
    }
  
    
}
- (void)clickSwitchBtn{
    if (self.isBigScreen == YES) {
        [self smallScreen];
    }
    else{
       
         [self bigScreen];
        
    }
    
}
//创建大屏幕
- (void)bigScreen{
//    self.isBigScreen = YES;
  
//    [UIView animateWithDuration:0.58 animations:^{
//        self.playerView.transform = CGAffineTransformMakeRotation(M_PI_2);
//        self.playerView.bounds = CGRectMake(0, AppNavitionHright, CGRectGetHeight(self.playerView.superview.bounds), CGRectGetWidth(self.playerView.superview.bounds));
//
//        self.playerView.center = CGPointMake(CGRectGetMidX(self.playerView.superview.bounds), CGRectGetMidY(self.playerView.superview.bounds));
//        [self.view addSubview:self.playerView];
////        self.headBackImgView.frame = self.playerView.frame;
//    } completion:^(BOOL finished) {
//        self.isBigScreen = YES;
//
//    }];
    
    UIView *PparentView = self.playerView;
    self.myView.frame = self.playerView.frame;
    CGRect rect = [self.playerView convertRect:self.playerView.bounds toView:[UIApplication sharedApplication].keyWindow];
    [self.playerView  removeFromSuperview];
    self.playerView.frame = rect;
    [[UIApplication sharedApplication].keyWindow  addSubview:self.playerView];
    
    [UIView animateWithDuration:0.5 animations:^{
//        self.playerView.transform = CGAffineTransformMakeRotation()
        self.playerView.transform = CGAffineTransformMakeRotation(M_PI_2);
//        self.playerView.frame = CGRectMake(0, 0,[UIApplication sharedApplication].keyWindow.frame.height,AppNavitionHright );
        self.playerView.frame = self.playerView.superview.frame;
        self.playerView.center = CGPointMake(self.playerView.superview.center.x, self.playerView.superview.center.y);
        self.playerView.userInteractionEnabled = YES;
    } completion:^(BOOL finished) {
        self.isBigScreen =YES;
    }];
    
    
}
- (void)smallScreen{
    [self.playerView removeFromSuperview];
    
    [UIView animateWithDuration:0.5 animations:^{
         self.playerView.transform = CGAffineTransformIdentity;
//        self.playerView.transform = CGAffineTransformIdentity;
        self.playerView.frame = self.myView.frame;
//        [self.view addSubview:self.playerView];
       [self.headBackImgView addSubview:self.playerView];
  
    } completion:^(BOOL finished) {

        self.isBigScreen = NO;
    }];
    
    
    
    
}
- (void)clickAdvbtn{
    
   
    if ([User sharedUUser].isLogin == YES) {
        advisoryViewController *adv = [[advisoryViewController alloc]init];
        [self.navigationController pushViewController:adv animated:YES];
    }
    else{
        [ProgressHUD showText:@"请先登录" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:2.0];

    }

}

- (void)clickJoinBtn{
    if ( [User sharedUUser].isLogin == YES) {
//        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
        NSString *drivice_id  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
        NSDictionary *dic = @{
                              @"drivice_id":drivice_id,
                                @"user_id":[User sharedUUser].user_id,
                                @"kc_id":self.kc_id
                              };
        
        
        [CZNetWork post:@"https://i.zhongjianedu.com/ios.php/104/classes/insertclasses" params:dic success:^(id success) {
            NSString *str = success[@"event"];
//            if ([str isEqualToString:@"101"]) {
//                [ProgressHUD showText:@"无课程id" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:1.0];
//            }
            if ([str isEqualToString:@"100"]) {
                [ProgressHUD showText:@"已经成功加入，可前往个人中心-我的课程中查看" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:1.0];
            }
            else{
                [ProgressHUD showText:@"加入失败" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:1.0];
                
            }
//            if ([str isEqualToString:@"104"]) {
//                [ProgressHUD showText:@"加入失败" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:1.0];
//            }
            
        } failure:^(NSError *error) {
            
        }];
        
    }
    else{
        [ProgressHUD showText:@"请先登录" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:2.0];
        
    }
    
    
    
    
}

- (void)clickBackBtn{
    [ProgressHUD showText:@"请先选择要播放的目录" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:1.0];
    
}
-(void)addVideo :(NSString *)urlString{
    if ([judgeString isBlankString:urlString]) {
        [ProgressHUD showText:@"视频加载失败" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:1.0];
    }
    else{
        self.playerView.hidden = NO;
        self.playerBtn.hidden = NO;
        self.backBtn.hidden = YES;  
        NSString *userId = @"5042EE22ABD606E1";
        NSString *key = @"SgqVSpzjRsVtlPJ1iWYsOe8hahXt98Yo";
        self.playInfo = [[DWPlayInfo alloc]initWithUserId:userId andVideoId:urlString key:key hlsSupport:@"1"];
         self.playInfo.timeoutSeconds = 30;
         self.playInfo.mediatype = @"1";
//        playInfo.verificationCode = @"授权验证码，没有此功能不需要设置";
         self.playInfo.finishBlock = ^(DWVodVideoModel *vodVideo) {
            //成功回调
            NSLog(@"%@",vodVideo);
        };
         self.playInfo.errorBlock = ^(NSError *error) {
            //失败回调
            NSLog(@"shibai:%@",error);
        };
    [ self.playInfo start];
        __weak __typeof__(self)weakSelf = self;
        self.playInfo.finishBlock = ^(DWVodVideoModel *vodVideo) {
            //            NSLog(@"%@",vodVideo);
            
            [weakSelf.playerView playVodViedo:vodVideo withCustomId:nil];
            //            [self.playerView play];
            
        };

    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 118;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArr.count-1;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"secondDetaiCellid";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    cell.backgroundColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(10, 13, ScreenWidth- 20, 105)];
    [cell.contentView addSubview:backView];
    backView.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
    backView.backgroundColor = [UIColor whiteColor];
    backView.layer.cornerRadius = 10;
    backView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.05].CGColor;
    backView.layer.shadowOffset = CGSizeMake(0,1);
    backView.layer.shadowOpacity = 1;
    backView.layer.shadowRadius = 2;
    myLable *topLable =[[myLable alloc]initWithFrame:CGRectMake(6, 10, ScreenWidth, 45)];
//    int i= (int)indexPath.row+1;
    topLable.text = self.dataArr[indexPath.row+1][@"bt"];
    [backView addSubview:topLable];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    NSString *Str = self.dataArr[indexPath.row+1][@"url"];
   
    [self addVideo:Str];
}
-(void)clickTheButtonToStartPlaying{
    if ([User sharedUUser].isLogin == YES) {
        [self.playerView play];
        self.playerBtn.hidden = YES;
        self.timeOutBtn.hidden = YES;
        self.smallPlayerBtn.hidden = NO;
    }
    else{
        [ProgressHUD showText:@"请先登录" icon:[UIImage imageNamed:@""] mode:MBProgressHUDModeText onView:self.view duration:2.0];
        
    }
   
}
//当前播放时间

-(void)videoPlayer:(DWPlayerView *)playerView timeDidChange:(float)time{
    
  
    CGFloat ducSec = (CGFloat)CMTimeGetSeconds(self.playerView.player.currentItem.duration);
    
//    NSString *minute1 = [NSString stringWithFormat:@"%d",(int)time/60];
//    NSString *second1 = [NSString stringWithFormat:@"%d",(int)time%60];
//
//    NSString *str1 = [NSString stringWithFormat:@"%@:%@",minute1,second1];
//    self.currentTimeLabel.text = [NSString stringWithFormat:@"%@",str1];
    self.currentTimeLabel.text = [DWTools formatSecondsToString:time];
    if (!isnan(ducSec)) {
         self.durationSlider.value = time/ducSec;
//        self.totalTimeLabel.text = [NSString stringWithFormat:@"%f",ducSec];
//        NSLog(@"%f",ducSec);
//        NSString *minute = [NSString stringWithFormat:@"%d",(int)ducSec/60];
//         NSString *second = [NSString stringWithFormat:@"%d",(int)ducSec%60];
//
//        NSString *str = [NSString stringWithFormat:@"%@:%@",minute,second];
//        self.totalTimeLabel.text = [NSString stringWithFormat:@"%@",str];
        self.totalTimeLabel.text = [DWTools formatSecondsToString:ducSec];
//        self.durationProgress.progress = time/ducSec;
    }
    
  
   
}


////播放完毕
//- (void)videoPlayerDidReachEnd:(DWPlayerView *)playerView{
//
//
//
//
//}

-(UITableView *)TableView{
    if (!_TableView) {
        _TableView = [[UITableView alloc] init];
        _TableView.delegate  =self;
        _TableView.dataSource  =self;
        [_TableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"secondDetaiCellid"];
        _TableView.backgroundColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
        _TableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _TableView;
    
}

- (void)getaData{
    __weak __typeof__(self)weakSelf = self;
    NSDictionary *dic = @{
                          @"kc_id":self.kc_id,
                          
                          };
    
    [CZNetWork post:@"https://i.zhongjianedu.com/ios.php/104/classes/viewclasses" params:dic success:^(id success) {
        
        NSArray *arr =success[@"memu_list"];
          [self.dataArr removeAllObjects];
        for (int i = 0; i<arr.count; i++) {
            [self.dataArr addObject:arr[i]];
        }
        [weakSelf.TableView reloadData];
//        NSMutableArray *Arry = [[NSMutableArray alloc]init];
//        for (int i = 0; i<arr.count; i++) {
//            [Arry addObject:arr[i]];
//        }
//       NSMutableArray *Ary = [[NSMutableArray alloc]init];
//        for (int j = 0; j<Arry.count; j++) {
//            [self.dataArr addObject:Arry[j][@"url"]];
//            NSString *str =self.dataArr[j];
//            if([judgeString isBlankString:str]) {
//
//            }
//            else{
//                [Ary addObject:str];
//            }
//
//        }
//        [weakSelf addVideo:Ary[0]];
//
        
    } failure:^(NSError *error) {
    
        
        
    }];
   
}
-(NSMutableArray *)dataArr{
    if (!_dataArr) {
        _dataArr = [[NSMutableArray alloc]init];
    }
    return _dataArr;
}
- (UIButton *)advisoryBtn{
    if (!_advisoryBtn) {
        _advisoryBtn = [[UIButton alloc]init];
        _advisoryBtn.backgroundColor = [UIColor colorWithRed:255/255.0 green:194/255.0 blue:9/255.0 alpha:1.0];
        [_advisoryBtn setTitle:@"咨询" forState:UIControlStateNormal];
        [_advisoryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _advisoryBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        
    }
    
    return _advisoryBtn;
}
- (UIButton *)joinBtn{
    if (!_joinBtn) {
        _joinBtn = [[UIButton alloc]init];
        _joinBtn.backgroundColor = [UIColor colorWithRed:26/255.0 green:74/255.0 blue:199/255.0 alpha:1.0];
        [_joinBtn setTitle:@"加入课程" forState:UIControlStateNormal];
        [_joinBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _joinBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        
    }
    
    return _joinBtn;
  
}
- (UILabel *)totalTimeLabel{
    if (!_totalTimeLabel) {
        _totalTimeLabel = [[UILabel alloc]init];
        _totalTimeLabel.textColor = [UIColor whiteColor];
        _totalTimeLabel.font = [UIFont systemFontOfSize:12];
//        _totalTimeLabel.backgroundColor = [UIColor redColor];
    }
    return _totalTimeLabel;
}
- (UILabel *)currentTimeLabel{
    if (!_currentTimeLabel) {
        _currentTimeLabel = [[UILabel alloc]init];
        _currentTimeLabel.textColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
        _currentTimeLabel.font = [UIFont systemFontOfSize:12];
        
    }
    return _currentTimeLabel;

}
- (UIView *)myView{
    if (!_myView) {
        _myView = [[UIView alloc]init];
    }
    return _myView;
}
-(UIButton *)smallPlayerBtn{
  
    if (!_smallPlayerBtn) {
        _smallPlayerBtn = [[UIButton alloc]init];
        [_smallPlayerBtn setImage:[UIImage imageNamed:@"samllplay"] forState:UIControlStateNormal];
    }
    return _smallPlayerBtn;
}
-(UIButton *)timeOutBtn{
    if (!_timeOutBtn) {
        _timeOutBtn = [[UIButton alloc]init];
        [_timeOutBtn setImage:[UIImage imageNamed:@"player"] forState:UIControlStateNormal];
    }
    return _timeOutBtn;
    
    
}



@end
